package com.yinp.proapp.greendao;

import com.yinp.proapp.base.App;
import com.yinp.proapp.module.task.bean.LocaleTaskBean;
import com.yinp.tools.utils.DateUtils;

import org.greenrobot.greendao.AbstractDao;

import java.util.List;

/**
 * @author :yinpeng
 * date      :2021/9/2
 * package   :com.yinp.proapp.greendao
 * describe  :
 */
public class DealLocaleTask<T> extends DaoUtils<T> {
    public DealLocaleTask() {
        super((Class<T>) LocaleTaskBean.class, (AbstractDao<T, Long>) App.daoSession.getLocaleTaskBeanDao());
    }

    /**
     * 查询是否结束的任务
     *
     * @return
     */
    public List<LocaleTaskBean> queryIsFinishList(boolean isFinish, int page) {
        return queryIsFinishList(isFinish, page, size);
    }

    public List<LocaleTaskBean> queryIsFinishList(boolean isFinish, int page, int size) {
        return mDaoSession.queryBuilder(LocaleTaskBean.class).offset((page - 1) * size).limit(size).where(LocaleTaskBeanDao.Properties.IsFinish.eq(isFinish)).list();
    }

    /**
     * 查找今日未完成的待做
     *
     * @param page
     * @return
     */
    public List<LocaleTaskBean> queryCurDateNoFinishList(int page) {
        return queryCurDateNoFinishList(page, size);
    }

    public List<LocaleTaskBean> queryCurDateNoFinishList(int page, int size) {
        return mDaoSession.queryBuilder(LocaleTaskBean.class).offset((page - 1) * size).limit(size).where(LocaleTaskBeanDao.Properties.IsFinish.eq(false),
                LocaleTaskBeanDao.Properties.Date.eq(DateUtils.curData.curDate())).list();
    }

    /**
     * @param page
     * @return
     */
    public List<LocaleTaskBean> queryHistoryList(int page) {
        return queryHistoryList(page, size);
    }

    public List<LocaleTaskBean> queryHistoryList(int page, int size) {
        return mDaoSession.queryBuilder(LocaleTaskBean.class).offset((page - 1) * size).limit(size).whereOr(LocaleTaskBeanDao.Properties.Date.notEq(DateUtils.curData.curDate()),
                LocaleTaskBeanDao.Properties.IsFinish.eq(true)).list();
    }
}
